package com.tzl.design_pattern.template_method_pattern;

/**
 * @author Zhilei Tang
 * @date Created in 2020/11/14 21:26
 */
public abstract class CookingVegetables {

  protected final void cooking() {
    putOil();
    putVegetables();
    stirFry();
    putSalt();
    if (needSeasoning()) {
      putSeasoning();
    }
    disUp();
  }

  final void disUp() {
    System.out.println("菜炒好了,可以起锅了....");
  }

  abstract void putSeasoning();

  protected boolean needSeasoning() {
    return true;
  }

  final void putSalt() {
    System.out.println("放点盐....");
  }

  final void stirFry() {
    System.out.println("正在翻炒....");
  }

  final void putVegetables() {
    System.out.println("菜下锅了....");
  }

  final void putOil() {
    System.out.println("油下锅了....");
  }
}
